<?php

namespace app\index\controller;

use think\Controller;

class Addons extends Controller
{
    public function execute()
    {
        $_addons = request()->param('_addons');
        $_controller = request()->param('_controller');
        $_action = request()->param('_action');
        if (!empty($_addons) && !empty($_controller) && !empty($_action)) {
            // 获取类的命名空间
            $class = get_addons_class($_addons, 'controller', $_controller);
            if (class_exists($class)) {
                $model = new $class();
                if ($model === false) {
                    abort(500, lang('addon init fail'));
                }
                return call_user_func_array([$model, $_action], [$this->request]);
            } else {
                abort(500, lang('Controller Class Not Exists'));
            }
        }
        abort(500, lang('addon cannot name or action'));
    }
}